.PHONY: install dev install-dev test lint format clean run example

# 默认目标
help:
	@echo "可用命令："
	@echo "  install      - 安装项目依赖"
	@echo "  install-dev  - 安装开发依赖"
	@echo "  dev          - 安装开发模式"
	@echo "  test         - 运行测试"
	@echo "  test-cov     - 运行测试并生成覆盖率报告"
	@echo "  lint         - 代码检查"
	@echo "  format       - 代码格式化"
	@echo "  run          - 启动 Flask 应用"
	@echo "  example      - 运行使用示例"
	@echo "  clean        - 清理构建文件"

# 安装依赖
install:
	pip install -r requirements.txt

# 安装开发依赖
install-dev:
	pip install -e .[dev]

# 开发模式安装
dev:
	pip install -e .

# 运行测试
test:
	pytest

# 运行测试并生成覆盖率报告
test-cov:
	pytest --cov=src --cov-report=html --cov-report=term

# 代码检查
lint:
	flake8 .
	mypy src/

# 代码格式化
format:
	black .
	isort .

# 启动 Flask 应用
run:
	python3 -m src.marketStream.main

# 运行使用示例
example:
	python3 example_usage.py

# 清理构建文件
clean:
	rm -rf build/
	rm -rf dist/
	rm -rf *.egg-info/
	rm -rf .pytest_cache/
	rm -rf .coverage
	rm -rf htmlcov/
	find . -type d -name __pycache__ -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete

# 构建发布包
build:
	python3 -m build
